package 剑指offer;

public class 剑指Offer21调整数组顺序使奇数位于偶数前面 {
    public int[] exchange(int[] nums) {
        if (nums.length == 0) return nums;
        int left = 0;
        int right = nums.length - 1;
        while(left != right){
            while(nums[left] % 2 == 1 &&  left < right){
                left ++;
            }
            while(nums[right] % 2 == 0 && right > left){
                right--;
            }
            int tem = nums[left];
            nums[left] = nums[right];
            nums[right] = tem;
        }
        return nums;
    }
}
